home *** CD-ROM | disk | FTP | other *** search
/ Aminet 31 / Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso / Aminet / dev / c / ctags.lha / ctags-3.0.3 / strstr.c < prev    next >
C/C++ Source or Header  |  1999-02-17  |  917b  |  39 lines

  1. /*****************************************************************************
  2. *   $Id: strstr.c,v 7.1 1998/12/07 01:38:00 darren Exp $
  3. *
  4. *   Copyright (c) 1996-1998, Darren Hiebert
  5. *
  6. *   This source code is released for free distribution under the terms of the
  7. *   GNU General Public License.
  8. *
  9. *   This module contains a substitute for a potentially missing ANSI C
  10. *   function.
  11. *****************************************************************************/
  12. #ifdef HAVE_CONFIG_H
  13. # include <config.h>
  14. #endif
  15. #include <string.h>
  16.  
  17. #ifndef HAVE_STRSTR
  18.  
  19. extern char * strstr( str, substr )
  20.     const char *const str;
  21.     const char *const substr;
  22. {
  23.     const size_t length = strlen(substr);
  24.     const char *match = NULL;
  25.     const char *p;
  26.  
  27.     for (p = str  ;  *p != '\0'  ;  ++p)
  28.     if (strncmp(p, substr, length) == 0)
  29.     {
  30.         match = p;
  31.         break;
  32.     }
  33.     return match;
  34. }
  35.  
  36. #endif
  37.  
  38. /* vi:set tabstop=8 shiftwidth=4: */
  39.